package com.tg.app.activity.device.list;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.base.BaseFragment;
import com.tg.app.R;

public class MineFragment extends BaseFragment {

    public static final String TAG = "HomeFragmentTAG";

    private ViewGroup rootView;

    private MineViewContainer mineViewContainer;

    private DeviceListFragment deviceListFragment;

    public static MineFragment newInstance() {
        MineFragment fragment = new MineFragment();
        Bundle args = new Bundle();
        fragment.setArguments(args);
        return fragment;
    }

    public void setDeviceListFragment(DeviceListFragment deviceListFragment) {
        this.deviceListFragment = deviceListFragment;
    }

    public boolean onBackKeyClicked() {
        return false;
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        rootView = (ViewGroup) inflater.inflate(R.layout.fragment_tange_common_container, container, false);
        mineViewContainer = new MineViewContainer(getActivity());
        mineViewContainer.attach(rootView);
        mineViewContainer.setCallback(new MineViewContainer.Callback() {
            @Override
            public void showLoadingView(String msg) {
                showLoading(msg);
            }

            @Override
            public void hideLoadingView() {
                hideLoading();
            }

            @Override
            public void onClickButton() {
                // do nothing
            }
        });
        if (deviceListFragment != null) {
            mineViewContainer.setDeviceCount(deviceListFragment.getDeviceCount());
            // 这是为了更新数量
            deviceListFragment.setMineViewContainer(mineViewContainer);
        }
        return rootView;
    }
}
